﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SomethingSpacial.Views.MixItUp;

namespace SomethingSpacial.Views.MixItUp
{
    public partial class BasePage : UserControl
    {
        Boolean onMainPage = true;

        public BasePage()
        {
            InitializeComponent();
            canvasHome.MouseLeftButtonUp += new MouseButtonEventHandler(canvasHome_MouseLeftButtonUp);
            buttonRegister.MouseLeftButtonUp += new MouseButtonEventHandler(buttonRegister_MouseLeftButtonUp);
            buttonPrintBadge.MouseLeftButtonUp += new MouseButtonEventHandler(buttonPrintBadge_MouseLeftButtonUp);
            buttonViewPresentationRoom.MouseLeftButtonUp += new MouseButtonEventHandler(buttonViewPresentationRoom_MouseLeftButtonUp);
            animationHideChildScreen.Completed += new EventHandler(animationHideChildScreen_Completed);
            badgeTextBlock.MouseLeftButtonUp += new MouseButtonEventHandler(badgeTextBlock_MouseLeftButtonUp);
            registrationTextBlock.MouseLeftButtonUp += new MouseButtonEventHandler(registrationTextBlock_MouseLeftButtonUp);
            presentationTextBlock.MouseLeftButtonUp += new MouseButtonEventHandler(presentationTextBlock_MouseLeftButtonUp);
        }

        void presentationTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("ViewPresentation");
        }

        void registrationTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("Register");
        }

        void badgeTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("PrintBadge");
        }


        void animationHideChildScreen_Completed(object sender, EventArgs e)
        {
        //    stackPanelChildControls.Children.Clear();

        }

        void canvasHome_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            animationHideChildScreen.Begin();
            animationMoveRight.Begin();
            onMainPage = true;
            
        }

        void buttonViewPresentationRoom_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("ViewPresentation");
        }

        void buttonPrintBadge_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("PrintBadge");
        }

        void buttonRegister_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToSubPage("Register");
        }



        void SwitchToSubPage(string PageName)
        {

            if (onMainPage)
            {
                animationMoveLeft.Begin();
            }

            onMainPage = false;
            animationHideChildScreen.Begin();
            stackPanelChildControls.Children.Clear();
            switch (PageName.ToLower())
            {
                case "viewpresentation":
                    stackPanelChildControls.Children.Add(new ViewPresentationRoom());
                    break;

                case "printbadge":
                    stackPanelChildControls.Children.Add(new PrintBadgeRoom());
                    break;

                case "register":
                    stackPanelChildControls.Children.Add(new Register());
                    break;
            }
            animationShowChildScreen.Begin();
        }

    }
}
